<script setup lang='ts'>
  import { reactive, ref } from 'vue';
  import { useRouter } from 'vue-router';
  import xmswiper from './components/xmswiper.vue';
  import goodsList from './components/goodsList.vue';
  import boxback from './components/boxback.vue';
  const rewardListRef = ref()
  const action = reactive({
    boxInfo:{
      price:0,
      name:'',
      pool:[] as Array<any>
    }
  })
  const $router = useRouter()
  const swiperChange = (query:any = {})=>{
    rewardListRef.value.scrollTo(0,0)
    action.boxInfo = query
  }
  const openRule = ()=>{
    $router.push({path:'/ruletext'})
  }
</script>

<template>
  <div class="content">
    <img @click="openRule" src="@/assets/images/butimg1.png" class="ruleButImg">
    <div class="contBox mb-24">
      <img src="@/assets/images/titleimg1.png" class="titleImg">
      <boxback :iconNum="2" class="boxBorder giftList">
        <xmswiper @swiperChange="swiperChange" />
        <div class="giftInfo">
          <div class="font name">{{ action.boxInfo.name }}</div>
          <div class="priceBox flex-align-center">
            <div class="price">
              <img src="@/assets/images/icon1.png" class="iconImg">
              <span class="font">{{ action.boxInfo.price }}</span>
            </div>
            <span class="font m-x4">/</span>
            <div class="price">
              <img src="@/assets/images/icon2.png" class="iconImg">
              <span class="font">{{ action.boxInfo.price }}</span>
            </div>
          </div>
        </div>
        <div class="rewardList">
          <div ref="rewardListRef" class="overflow-x flex">
            <div class="rewardInfo" v-for="item in action.boxInfo.pool" >
              <div class="image">
                <img :src="item.img">
              </div>
              <div class="name">{{ item.name }}</div>
              <div class="price">价值:{{ item.price }}钻</div>
              <div class="rate">{{ item.rate }}%概率</div>
            </div>
          </div>
        </div>
      </boxback>
    </div>
    <goodsList />
  </div>
</template>

<style lang='scss' scoped>
  .content {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 228px 10px 80px;
    box-sizing: border-box;
    background: #3C2A60 url('@/assets/images/banner1.png') left top / 100% 234px no-repeat;
    :deep(.contBox) {
      position: relative;
      padding-top: 26px;
      .titleImg {
        z-index: 10;
        position: absolute;
        top: 0;
        left: 50%;
        width: auto;
        height: 41px;
        transform: translateX(-50%);
      }
    }
    .ruleButImg {
      position: absolute;
      top: 149px;
      right: 0;
      width: 48px;
      height: 22px;
    }
    .giftList {
      padding: 25px 0 0;
      box-sizing: border-box;
      .giftInfo {
        padding: 10px 0 0;
        .font {
          font-size: 14px;
          font-weight: 500;
          color: #FFEED5;
          line-height: 14px;
        }
        .name {
          text-align: center;
          margin-bottom: 6px;
        }
        .m-x4 {
          margin: 0 4px;
        }
        .priceBox {
          .price {
            display: flex;
            align-items: center;
            .iconImg {
              width: 16px;
              height: 16px;
              margin-right: 4px;
            }
          }
        }
      }
      .overflow-x {
        overflow-y: hidden;
        overflow-x: auto;
      }
      .rewardList {
        height: 192px;
        margin-top: 8px;
        padding: 22px 14px 0;
        box-sizing: border-box;
        background: url('@/assets/images/backimg2.png') left top / 100% 100% no-repeat;
        .rewardInfo {
          min-width: 84px;
          max-width: 84px;
          margin-right: 12px;
          .image {
            width: 84px;
            height: 84px;
            padding: 6px;
            box-sizing: border-box;
            background: linear-gradient(360deg, #0C0442 0%, #000A18 100%);
            border-radius: 8px;
            border: 1px solid #5E6ABC;
          }
          .name, .price {
            text-align: center;
          }
          .name {
            color: #FFEED5;
            font-size: 14px;
            font-weight: 400;
            line-height: 14px;
            margin-top: 6px;
          }
          .price {
            color: #FFEED5;
            font-size: 12px;
            font-weight: 400;
            line-height: 12px;
            margin: 7px 0;
          }
          .rate {
            width: max-content;
            height: 16px;
            line-height: 16px;
            color: #000;
            font-size: 12px;
            font-weight: 500;
            margin: 0 auto;
            padding: 0 5px;
            box-sizing: border-box;
            background: #FFEED5;
            border-radius: 8px;
          }
        }
      }
      .overflow-x::-webkit-scrollbar {
        display: none;
      }
    }
  }
</style>